package com.xysl.controller;

import java.util.List;
import java.io.IOException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.xysl.api.domain.UserCustomizeValue;
import com.xysl.service.IUserCustomizeValueService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * xysl用户自定义配置参数Controller
 *
 * @author xysl
 * @date 2025-01-23
 */
@Hidden
@RestController
@RequestMapping("/value")
public class UserCustomizeValueController extends BaseController
{
    @Resource
    private IUserCustomizeValueService userCustomizeValueService;

    /**
     * 查询xysl用户自定义配置参数列表
     */
    @RequiresPermissions("enroll:value:list")
    @GetMapping("/list")
    public TableDataInfo list(UserCustomizeValue userCustomizeValue)
    {
        startPage();
        List<UserCustomizeValue> list = userCustomizeValueService.selectUserCustomizeValueList(userCustomizeValue);
        return getDataTable(list);
    }

    /**
     * 导出xysl用户自定义配置参数列表
     */
    @RequiresPermissions("enroll:value:export")
    @Log(title = "xysl用户自定义配置参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserCustomizeValue userCustomizeValue)
    {
        List<UserCustomizeValue> list = userCustomizeValueService.selectUserCustomizeValueList(userCustomizeValue);
        ExcelUtil<UserCustomizeValue> util = new ExcelUtil<UserCustomizeValue>(UserCustomizeValue.class);
        util.exportExcel(response, list, "xysl用户自定义配置参数数据");
    }

    /**
     * 获取xysl用户自定义配置参数详细信息
     */
    @RequiresPermissions("enroll:value:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userCustomizeValueService.selectUserCustomizeValueById(id));
    }

    /**
     * 新增xysl用户自定义配置参数
     */
    @RequiresPermissions("enroll:value:add")
    @Log(title = "xysl用户自定义配置参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserCustomizeValue userCustomizeValue)
    {
        return toAjax(userCustomizeValueService.insertUserCustomizeValue(userCustomizeValue));
    }

    /**
     * 修改xysl用户自定义配置参数
     */
    @RequiresPermissions("enroll:value:edit")
    @Log(title = "xysl用户自定义配置参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserCustomizeValue userCustomizeValue)
    {
        return toAjax(userCustomizeValueService.updateUserCustomizeValue(userCustomizeValue));
    }

    /**
     * 删除xysl用户自定义配置参数
     */
    @RequiresPermissions("enroll:value:remove")
    @Log(title = "xysl用户自定义配置参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userCustomizeValueService.deleteUserCustomizeValueByIds(ids));
    }
}
